# models/sys_dict_table.py
from sqlalchemy import Column, String, DateTime, Boolean
from src.core.ormdb import Base
from src.core import str_utils as strU


class SysDictTable(Base):
    __tablename__ = "sys_dict_table"
    __table_args__ = {"comment": "数字字典表模式"}

    id = Column(String(36), primary_key=True, default=lambda: strU.generate_id(), comment="ID")
    api_id = Column(String(36), nullable=True, comment="API主键，用于关联其他系统")
    dict_value = Column(String(36), nullable=False, comment="值")
    dict_code = Column(String(36), nullable=False, comment="字典代码")
    dict_text = Column(String(36), nullable=False, comment="字典名称")
    dict_disabled = Column(String(128), nullable=False, comment="禁用")
    table_name = Column(String(64), nullable=False, comment="表名")
    conditional = Column(String(1024), nullable=False, comment="条件/排序语句")
    dict_id = Column(String(36), nullable=False, comment="字典ID")
    dict_root = Column(Boolean, default=False,comment="是否需要跟目录")
    enabled = Column(Boolean, default=True, comment="可用")
    deletion_mark = Column(Boolean, default=False, comment="删除标志，0 表示未删除，1 表示已删除")
    deletion_reason = Column(String(255), nullable=True, comment="删除原因")
    deletion_date = Column(DateTime, nullable=True, comment="删除日期")
    deletion_by = Column(String(255), nullable=True, comment="删除者")
    create_date = Column(DateTime, default=lambda: strU.now(), comment="创建日期")
    creator_by = Column(String(255), nullable=True, comment="创建者")
    last_updated_date = Column(DateTime, nullable=True, comment="最后更新时间")
    last_updated_by = Column(String(255), nullable=True, comment="最后更新者")
    description = Column(String(128), nullable=True, comment="说明描述")
